Draft
Conversation
Some linkers emit PT_LOAD segments where filesz == memsz but contain .bss sections whose VMA range overlaps with file bytes from unrelated sections. The loader copies the full segment verbatim, leaving .bss with stale data instead of zeros. Collect NOBITS section ranges (excluding .tbss) during ELF parsing and zero-fill them after loading PT_LOAD segments. Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com> Co-authored-by: danbugs <danilochiarlone@gmail.com>
Remove the nanvix-unstable-gated file_mappings field from HyperlightPEB and all host-side code that wrote to it: - write_file_mapping_entry in mgr.rs - PEB layout calculations (array sizing, heap offset, getter methods) - PEB file_mapping writes in write_peb and map_file_cow - 3 PEB test functions (multiuse, deferred, multiple_entries) - evolve-time write_file_mapping_entry call Embedders that need file mapping metadata can pass it through init_data instead of the PEB struct. Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com> Co-authored-by: danbugs <danilochiarlone@gmail.com>
…eatures Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com> Co-authored-by: danbugs <danilochiarlone@gmail.com>
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com> Co-authored-by: danbugs <danilochiarlone@gmail.com>
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com> Co-authored-by: danbugs <danilochiarlone@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces initial support for i686 (32-bit) guests in Hyperlight’s snapshot/restore pipeline, while also cleaning up/renaming feature gates (splitting the prior nanvix-unstable usage into i686-guest and guest-counter) and removing the deprecated PEB file-mapping bookkeeping.
Changes:
- Add i686-specific snapshot capture/compaction logic, including multi-PD-root support and separate PT storage during restore.
- Rename/replace
nanvix-unstablefeature usage withi686-guestandguest-counteracross host/common/guest crates and build tooling. - Improve ELF loading correctness by collecting NOBITS ranges and explicitly zero-filling them after PT_LOAD copies.
Reviewed changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/hyperlight_host/src/sandbox/uninitialized_evolve.rs | Switch scratch HostSharedMemory publication to guest-counter feature gate. |
| src/hyperlight_host/src/sandbox/uninitialized.rs | Rename cfg gates for GuestCounter and related deferred scratch plumbing. |
| src/hyperlight_host/src/sandbox/snapshot.rs | Add i686 snapshot/PT walking + compaction + separate PT bytes handling; adjust root PT handling to support multiple roots. |
| src/hyperlight_host/src/sandbox/initialized_multi_use.rs | Discover i686 PD roots via scratch bookkeeping; plumb root list into snapshot creation; remove PEB file-mapping tests/logic. |
| src/hyperlight_host/src/sandbox/file_mapping.rs | Make mapping label field always #[allow(unused)] after PEB metadata removal. |
| src/hyperlight_host/src/mem/shared_mem.rs | Update test-only HostSharedMemory accessor cfg to guest-counter. |
| src/hyperlight_host/src/mem/mgr.rs | Update snapshot API to accept multiple roots; add i686 restore path copying separate PT bytes into scratch; refactor PT copy helper. |
| src/hyperlight_host/src/mem/memory_region.rs | Update cfg attributes from nanvix-unstable to i686-guest. |
| src/hyperlight_host/src/mem/layout.rs | Remove PEB file-mappings reserved area/offsets and unify BASE_ADDRESS; update cfg attributes to i686-guest. |
| src/hyperlight_host/src/mem/exe.rs | Expose ExeInfo::base_va() for correct entrypoint computation when base VA ≠ 0. |
| src/hyperlight_host/src/mem/elf.rs | Collect NOBITS section ranges and zero-fill them after PT_LOAD segment copy. |
| src/hyperlight_host/src/lib.rs | Re-export GuestCounter under guest-counter. |
| src/hyperlight_host/src/hypervisor/virtual_machine/whp.rs | Gate XSAVE test helper with not(i686-guest). |
| src/hyperlight_host/src/hypervisor/virtual_machine/mshv/x86_64.rs | Gate XSAVE test helper with not(i686-guest). |
| src/hyperlight_host/src/hypervisor/virtual_machine/mod.rs | Gate XSAVE constant/test API with not(i686-guest). |
| src/hyperlight_host/src/hypervisor/virtual_machine/kvm/x86_64.rs | Gate XSAVE test helper with not(i686-guest). |
| src/hyperlight_host/src/hypervisor/regs/x86_64/special_regs.rs | Add i686 protected-mode-with-paging sregs defaults and update cfg usage. |
| src/hyperlight_host/src/hypervisor/hyperlight_vm/x86_64.rs | Use i686 paging defaults when i686-guest; simplify get_root_pt / restore sregs logic. |
| src/hyperlight_host/build.rs | Remove nanvix-unstable from unshared_snapshot_mem alias (now only gdb). |
| src/hyperlight_host/Cargo.toml | Replace nanvix-unstable with i686-guest and guest-counter features. |
| src/hyperlight_guest/src/layout.rs | Gate guest counter pointer helper behind guest-counter. |
| src/hyperlight_guest/Cargo.toml | Replace nanvix-unstable with i686-guest and guest-counter. |
| src/hyperlight_common/src/vmem.rs | Re-export host-side i686 PT walker module when i686-guest on x86_64 hosts. |
| src/hyperlight_common/src/mem.rs | Remove PEB file_mappings field. |
| src/hyperlight_common/src/layout.rs | Use i686 arch layout when i686-guest on x86_64; add PD-roots bookkeeping constants; gate guest-counter offset. |
| src/hyperlight_common/src/arch/i686/layout.rs | Replace dummy layout with real min scratch size calculation for i686 mode. |
| src/hyperlight_common/src/arch/amd64/vmem.rs | Add host-side i686 2-level PT walker/constants under i686-guest. |
| src/hyperlight_common/Cargo.toml | Replace nanvix-unstable with i686-guest and guest-counter. |
| Justfile | Update CI/dev cargo check feature sets from nanvix-unstable to i686-guest. |
| }; | ||
| #[allow(clippy::unwrap_used)] | ||
| let n: [u8; 4] = pte_bytes.try_into().unwrap(); | ||
| u32::from_ne_bytes(n) as u64 |
Comment on lines
+470
to
+474
| // i686 snapshots store PT bytes separately (not appended to shared_mem) | ||
| // to avoid overlapping with map_file_cow regions. | ||
| // x86_64 snapshots have PTs appended to shared_mem. | ||
| #[cfg(feature = "i686-guest")] | ||
| { |
Comment on lines
+25
to
27
| #[cfg(all(feature = "i686-guest", target_arch = "x86_64"))] | ||
| pub use arch::i686_guest; | ||
| pub use arch::{PAGE_TABLE_SIZE, PageTableEntry, PhysAddr, VirtAddr}; |
Comment on lines
+296
to
+300
| /// Build a CoW resolution map by walking a kernel PD. | ||
| /// For each PTE that maps a VA in [0, MEMORY_SIZE) to a PA in scratch, | ||
| /// record: original_gpa -> scratch_gpa. | ||
| #[cfg(feature = "i686-guest")] | ||
| fn build_cow_map( |
Comment on lines
+226
to
+227
| let sh_start = (addr - base_va) as usize; | ||
| let sh_end = sh_start + size as usize; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
needs #1380 and #1379, will mark ready then
Adds support for i686 guests